package com.fh.pms.controller;


import com.alibaba.fastjson.JSON;
import com.fh.pms.entity.Product;
import com.fh.pms.service.IProductService;
import com.fh.result.ResultObject;
import com.fh.search.ProductBusiness;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author F
 * @since 2021-05-24
 */
@RestController
@RequestMapping("/product")
public class ProductController {


     @Autowired
    private IProductService iProductService;

    @PostMapping
    public  ResultObject saveOrUpdateProduct(@RequestBody ProductBusiness productBusiness){
       iProductService.saveOrUpdateProduct(productBusiness);

        return ResultObject.success();
    }

    //查询
    @GetMapping
    public ResultObject queryProduct(){
        List<Product> list = iProductService.list();
        return  ResultObject.success(list);
    }
    //修改状态
    @PostMapping("/updateStatus")
    public ResultObject updateStatus(@RequestBody Product pmsProduct){
        iProductService.updateById(pmsProduct);
        return  ResultObject.success();
    }

    @PostMapping("/updateDeleteStatus")
    public ResultObject updateDeleteStatus(@RequestBody Product product){
        return iProductService.updateDeleteStatus(product);
    }

}
